using System;
using System.Reflection;
using NBody;
using NBody.Analysis;
using OptionParser;

[assembly: AssemblyTitle ("NBodyRotate")]
[assembly: AssemblyVersion ("1.0.*")]
[assembly: AssemblyDescription ("Roate the N-body system.")]
[assembly: AssemblyCopyright ("2005 Joseph D. MacMillan")]

public class RotateOptions : InputOutputGetOptions
{
    [Option ("-x", "Rotate about x axis (degrees)")]
    public double XAngle;
    
    [Option ("-y", "Rotate about y axis (degrees)")]
    public double YAngle;
    
    [Option ("-z", "Rotate about z axis (degrees)")]
    public double ZAngle;
    
    [Option ("-m", "Rotate by matrix in file")]
    public string MatrixFile;
    
    public RotateOptions()
    {
        XAngle = 0.0;
        YAngle = 0.0;
        ZAngle = 0.0;
        MatrixFile = "";
    }
}

public class NBodyRotate
{
    public static void Main(string[] args)
    {
        RotateOptions opts = new RotateOptions();
        opts.ProcessArgs(args, ".rot");
                        
        NBodySystem s = NBodySystem.Read(opts.InFile);
        
        if (opts.XAngle != 0.0)
            s.RotateAboutX(opts.XAngle);
        if (opts.YAngle != 0.0)
            s.RotateAboutY(opts.YAngle);
        if (opts.ZAngle != 0.0)
            s.RotateAboutZ(opts.ZAngle);
        
        if (opts.MatrixFile != "")
        {
            DataFile.Table a =  DataFile.Table.Read(opts.MatrixFile);
            s.RotateByMatrix(a.Array);
        }
        
        s.Write(opts.OutFile);
    }
}
